<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>狭义闭包</h2>
</body>
<script>
    function getCount() {
        let i = 0;

        const add = function() {
            i++;
            console.log(i)
        }

        return add;
    }


    const res = getCount()

    res()
    res()
    res()
    res()
    const res2 = getCount()
    res2() //1
    res2() //2
</script>

</html>